using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Contracts.Contracts;
using Simple.Contracts.Models;
using Simple.Contracts.Models.Common;
using Simple.WebAi.Authorizes;
using System.ComponentModel.DataAnnotations;

namespace Simple.WebAi.Controllers
{
    /// <summary>
    /// 照护任务分类控制器
    /// </summary>
    [Route("api/care-mission-categorize")]
    [ApiController]
    public class CareMissionCategorizeController : ControllerBase
    {
        private readonly ICareMissionCategorizeService _careMissionCategorizeService;

        /// <summary>
        /// 依赖注入
        /// </summary>
        /// <param name="careMissionCategorizeService">照护任务分类服务</param>
        public CareMissionCategorizeController(ICareMissionCategorizeService careMissionCategorizeService)
        {
            _careMissionCategorizeService = careMissionCategorizeService;
        }

        /// <summary>
        /// 获取照护任务分类列表
        /// </summary>
        /// <returns>照护任务分类列表</returns>
        [HttpPost("list")]
        [AccountAuthorize]
        public async Task<Result<List<CareMissionCategorizeDto>>> List(CareMissionCategorizeListInput input)
        {
            return await _careMissionCategorizeService.List(input);
        }

        /// <summary>
        /// 保存照护任务分类信息
        /// </summary>
        /// <param name="input">照护任务分类保存参数</param>
        /// <returns>保存结果</returns>
        [HttpPost("save")]
        [AccountAuthorize]
        public async Task<Result<long>> Save(CareMissionCategorizeSaveInput input)
        {
            return await _careMissionCategorizeService.Save(input);
        }

        /// <summary>
        /// 更新照护任务分类排序值
        /// </summary>
        /// <param name="input">排序更新输入</param>
        /// <returns>更新结果</returns>
        [HttpPost("sort")]
        [AccountAuthorize]
        public async Task<Result<bool>> UpdateSort(CareMissionCategorizeSortInput input)
        {
            return await _careMissionCategorizeService.UpdateSort(input);
        }

        /// <summary>
        /// 删除照护任务分类
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost("delete")]
        [AccountAuthorize]
        public async Task<Result<bool>> Delete([FromQuery][Required] long id)
        {
            return await _careMissionCategorizeService.Delete(id);
        }
    }
}